package com.ruoyi.common.utils.jier;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 公司工具类
 *
 * @author YanJun Sun
 */
public class PartUtils {

    /**
     * 检查是否为数组成员
     *
     * @return boolean
     */
    public static boolean nameLoop(String[] arr, String targetValue) {
        for(String s: arr){
            if(s.equals(targetValue)) {
                return true;
            }
        }
        return false;
    }

    /**
     * 获取合同号
     *
     * @return boolean
     */
    public static String matchContractNumber(String partNumber){
        String pattern = "^(.*?)[,.!?-]";
        Pattern regex = Pattern.compile(pattern);
        Matcher matcher = regex.matcher(partNumber);
        String result;
        if (matcher.find()) {
            result = matcher.group(1);
        } else {
            result = partNumber;
        }
        return result;
    }
}
